New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(forms): type NG_VALUE_ACCESSOR injection token correctly #29723
Conversation
Regarding the two failed CI jobs:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general.
A few things need to happen before this can be merged:
- Run public_api guard task to update goldens (cannot be merged while this test is red)
-yarn bazel run //tools/public_api_guard:forms_api.accept
- Update commit message to add more documentation about the change
- [Kara] Run through Google3 TAP to see how much of a breaking change this would be
@kara The command you listed fails for me with like below. Nonetheless, I think I should have updated everything accordingly.
|
Hi @Airblader, This change will most likely be breaking, so we can see if we can include it into one of the next major releases (v11). Could you please rebase this PR when you get a chance, so that I can run a new presubmit to estimate the effort that would be required to adapt g3 apps code to this change? Thank you, |
@AndrewKushnir I've rebased it. |
Thanks for the rebase @Airblader 👍 I've started g3 presubmit (+ global presubmit) to estimate the effort that'd be required to land this change. |
@Airblader, thanks for updating the PR, it looks like a couple CI jobs are failing (lint and test). Could you please have a look at the failures and update the code? Thank you. |
e488146
to
a2f7c57
Compare
@AndrewKushnir Should be fixed now. |
I had that, but the tests failed because they said it has to be like this. |
@Airblader could you please try to apply the changes to the
If there are failing tests after these changes, please let us know, we'll look into that. Thank you. |
NG_VALUE_ACCESSOR is a multi injection token, users can and should expect more than one ControlValueAccessor to be available (and this is how it is used in @angular/forms). This is now reflected in the definition of the injection token by typing it as an array of ControlValueAccessor. The motivating reason is that using the programmatic Injector api will now type Injector#get correspondingly. fixes angular#29351 BREAKING CHANGES NG_VALUE_ACCESSOR is now typed as a readonly array rather than a mutable scalar. It is used as a multi injection token and as such it should always be expected that more than one accessor may be returned.
@AndrewKushnir I updated it and ran the yarn command, which did not change the public-api to the same but instead retained Edit: Now updating it manually in the public-api and re-running the yarn command to see if it will undo that again. I won't push that but will let you know here what happened. Edit 2: Yeah, it undoes it and changes it back to |
a2f7c57
to
d9d75ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: public-api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-for: public-api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Reviewed-for: public-api
Quick update:
@Airblader thanks for contributing to Angular! 👍 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
fixes #29351
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
NG_VALUE_ACCESSOR
is typedControlValueAccessor
. This conflicts with it being used asmulti: true
when injecting it programmatically throughInjector#get
as the function is typed to return a singleControlValueAccessor
, even though it should be an array of them.Issue Number: #29351
What is the new behavior?
The injection token is now typed
ControlValueAccessor[]
.Does this PR introduce a breaking change?
Other information
I have not added any tests for this as it's purely a type information. This cannot be tested in an assertion kind of test, the only possibility would be a nop
Injector#get
call and making sure the TS compiler doesn't complain. This isn't a functional test, though, and I doubt we generally test that types are correct, so it seems unnecessary.